using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PlayHealth : MonoBehaviour
{
    public GameObject deathVFXPrefab;
    public GameObject deathPrefab;
    public LayerMask Tr;
    int trapsLayer;
    void Start()
    {
        trapsLayer = LayerMask.NameToLayer("Traps");

    }
    
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.gameObject.layer == trapsLayer)
        //if (collision.IsTouchingLayers(Tr))
        {
            Instantiate(deathVFXPrefab,transform.position,transform.rotation);
            Instantiate(deathPrefab, transform.position, Quaternion.Euler(0,0,Random.Range(-45,90)));
            //Instantiate(deathVFXPrefab, transform);
            gameObject.SetActive(false);
            AudioManager.PlayDeathAudio();
            GameManager.PlayerDied();
            //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }
    }
}
    
